﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.TouchScreenKeyboard
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Runtime.CompilerServices;
using UnityEngine.Bindings;
using UnityEngine.Internal;

#nullable disable
namespace UnityEngine
{
  /// <summary>
  ///   <para>Interface for on-screen keyboards. Only native iPhone, Android, and Windows Store Apps are supported.</para>
  /// </summary>
  [NativeHeader("Runtime/Input/KeyboardOnScreen.h")]
  [NativeHeader("Runtime/Export/TouchScreenKeyboard/TouchScreenKeyboard.bindings.h")]
  [NativeConditional("ENABLE_ONSCREEN_KEYBOARD")]
  public class TouchScreenKeyboard
  {
    [NonSerialized]
    internal IntPtr m_Ptr;

    [FreeFunction("TouchScreenKeyboard_Destroy", IsThreadSafe = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void Internal_Destroy(IntPtr ptr);

    private void Destroy()
    {
      if (this.m_Ptr != IntPtr.Zero)
      {
        TouchScreenKeyboard.Internal_Destroy(this.m_Ptr);
        this.m_Ptr = IntPtr.Zero;
      }
      GC.SuppressFinalize((object) this);
    }

    ~TouchScreenKeyboard() => this.Destroy();

    public TouchScreenKeyboard(
      string text,
      TouchScreenKeyboardType keyboardType,
      bool autocorrection,
      bool multiline,
      bool secure,
      bool alert,
      string textPlaceholder,
      int characterLimit)
    {
      this.m_Ptr = TouchScreenKeyboard.TouchScreenKeyboard_InternalConstructorHelper(ref new TouchScreenKeyboard_InternalConstructorHelperArguments()
      {
        keyboardType = Convert.ToUInt32((object) keyboardType),
        autocorrection = Convert.ToUInt32(autocorrection),
        multiline = Convert.ToUInt32(multiline),
        secure = Convert.ToUInt32(secure),
        alert = Convert.ToUInt32(alert),
        characterLimit = characterLimit
      }, text, textPlaceholder);
    }

    [FreeFunction("TouchScreenKeyboard_InternalConstructorHelper")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern IntPtr TouchScreenKeyboard_InternalConstructorHelper(
      ref TouchScreenKeyboard_InternalConstructorHelperArguments arguments,
      string text,
      string textPlaceholder);

    /// <summary>
    ///   <para>Is touch screen keyboard supported.</para>
    /// </summary>
    public static bool isSupported
    {
      get
      {
        switch (Application.platform)
        {
          case RuntimePlatform.IPhonePlayer:
          case RuntimePlatform.Android:
          case RuntimePlatform.MetroPlayerX86:
          case RuntimePlatform.MetroPlayerX64:
          case RuntimePlatform.MetroPlayerARM:
          case RuntimePlatform.PS4:
          case RuntimePlatform.tvOS:
          case RuntimePlatform.Switch:
          case RuntimePlatform.Stadia:
          case RuntimePlatform.GameCoreXboxSeries:
          case RuntimePlatform.GameCoreXboxOne:
          case RuntimePlatform.PS5:
            return true;
          default:
            return false;
        }
      }
    }

    internal static bool disableInPlaceEditing { get; set; }

    /// <summary>
    ///   <para>Checks if the text within an input field can be selected and modified while TouchScreenKeyboard is open.</para>
    /// </summary>
    /// <returns>
    ///   <para>Returns true when you are able to select and modify the input field, returns false otherwise.</para>
    /// </returns>
    public static bool isInPlaceEditingAllowed
    {
      get => TouchScreenKeyboard.disableInPlaceEditing && false;
    }

    internal static bool isRequiredToForceOpen => TouchScreenKeyboard.IsRequiredToForceOpen();

    [FreeFunction("TouchScreenKeyboard_IsRequiredToForceOpen")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool IsRequiredToForceOpen();

    /// <summary>
    ///   <para>Opens the native keyboard provided by OS on the screen.</para>
    /// </summary>
    /// <param name="text">Text to edit.</param>
    /// <param name="keyboardType">Type of keyboard (eg, any text, numbers only, etc).</param>
    /// <param name="autocorrection">Is autocorrection applied?</param>
    /// <param name="multiline">Can more than one line of text be entered?</param>
    /// <param name="secure">Is the text masked (for passwords, etc)?</param>
    /// <param name="alert">Is the keyboard opened in alert mode?</param>
    /// <param name="textPlaceholder">Text to be used if no other text is present.</param>
    /// <param name="characterLimit">How many characters the keyboard input field is limited to. 0 = infinite. (Android and iOS only)</param>
    public static TouchScreenKeyboard Open(
      string text,
      [DefaultValue("TouchScreenKeyboardType.Default")] TouchScreenKeyboardType keyboardType,
      [DefaultValue("true")] bool autocorrection,
      [DefaultValue("false")] bool multiline,
      [DefaultValue("false")] bool secure,
      [DefaultValue("false")] bool alert,
      [DefaultValue("\"\"")] string textPlaceholder,
      [DefaultValue("0")] int characterLimit)
    {
      return new TouchScreenKeyboard(text, keyboardType, autocorrection, multiline, secure, alert, textPlaceholder, characterLimit);
    }

    /// <summary>
    ///   <para>Opens the native keyboard provided by OS on the screen.</para>
    /// </summary>
    /// <param name="text">Text to edit.</param>
    /// <param name="keyboardType">Type of keyboard (eg, any text, numbers only, etc).</param>
    /// <param name="autocorrection">Is autocorrection applied?</param>
    /// <param name="multiline">Can more than one line of text be entered?</param>
    /// <param name="secure">Is the text masked (for passwords, etc)?</param>
    /// <param name="alert">Is the keyboard opened in alert mode?</param>
    /// <param name="textPlaceholder">Text to be used if no other text is present.</param>
    /// <param name="characterLimit">How many characters the keyboard input field is limited to. 0 = infinite. (Android and iOS only)</param>
    [ExcludeFromDocs]
    public static TouchScreenKeyboard Open(
      string text,
      TouchScreenKeyboardType keyboardType,
      bool autocorrection,
      bool multiline,
      bool secure,
      bool alert,
      string textPlaceholder)
    {
      int characterLimit = 0;
      return TouchScreenKeyboard.Open(text, keyboardType, autocorrection, multiline, secure, alert, textPlaceholder, characterLimit);
    }

    /// <summary>
    ///   <para>Opens the native keyboard provided by OS on the screen.</para>
    /// </summary>
    /// <param name="text">Text to edit.</param>
    /// <param name="keyboardType">Type of keyboard (eg, any text, numbers only, etc).</param>
    /// <param name="autocorrection">Is autocorrection applied?</param>
    /// <param name="multiline">Can more than one line of text be entered?</param>
    /// <param name="secure">Is the text masked (for passwords, etc)?</param>
    /// <param name="alert">Is the keyboard opened in alert mode?</param>
    /// <param name="textPlaceholder">Text to be used if no other text is present.</param>
    /// <param name="characterLimit">How many characters the keyboard input field is limited to. 0 = infinite. (Android and iOS only)</param>
    [ExcludeFromDocs]
    public static TouchScreenKeyboard Open(
      string text,
      TouchScreenKeyboardType keyboardType,
      bool autocorrection,
      bool multiline,
      bool secure,
      bool alert)
    {
      int characterLimit = 0;
      string textPlaceholder = "";
      return TouchScreenKeyboard.Open(text, keyboardType, autocorrection, multiline, secure, alert, textPlaceholder, characterLimit);
    }

    /// <summary>
    ///   <para>Opens the native keyboard provided by OS on the screen.</para>
    /// </summary>
    /// <param name="text">Text to edit.</param>
    /// <param name="keyboardType">Type of keyboard (eg, any text, numbers only, etc).</param>
    /// <param name="autocorrection">Is autocorrection applied?</param>
    /// <param name="multiline">Can more than one line of text be entered?</param>
    /// <param name="secure">Is the text masked (for passwords, etc)?</param>
    /// <param name="alert">Is the keyboard opened in alert mode?</param>
    /// <param name="textPlaceholder">Text to be used if no other text is present.</param>
    /// <param name="characterLimit">How many characters the keyboard input field is limited to. 0 = infinite. (Android and iOS only)</param>
    [ExcludeFromDocs]
    public static TouchScreenKeyboard Open(
      string text,
      TouchScreenKeyboardType keyboardType,
      bool autocorrection,
      bool multiline,
      bool secure)
    {
      int characterLimit = 0;
      string textPlaceholder = "";
      bool alert = false;
      return TouchScreenKeyboard.Open(text, keyboardType, autocorrection, multiline, secure, alert, textPlaceholder, characterLimit);
    }

    /// <summary>
    ///   <para>Opens the native keyboard provided by OS on the screen.</para>
    /// </summary>
    /// <param name="text">Text to edit.</param>
    /// <param name="keyboardType">Type of keyboard (eg, any text, numbers only, etc).</param>
    /// <param name="autocorrection">Is autocorrection applied?</param>
    /// <param name="multiline">Can more than one line of text be entered?</param>
    /// <param name="secure">Is the text masked (for passwords, etc)?</param>
    /// <param name="alert">Is the keyboard opened in alert mode?</param>
    /// <param name="textPlaceholder">Text to be used if no other text is present.</param>
    /// <param name="characterLimit">How many characters the keyboard input field is limited to. 0 = infinite. (Android and iOS only)</param>
    [ExcludeFromDocs]
    public static TouchScreenKeyboard Open(
      string text,
      TouchScreenKeyboardType keyboardType,
      bool autocorrection,
      bool multiline)
    {
      int characterLimit = 0;
      string textPlaceholder = "";
      bool alert = false;
      bool secure = false;
      return TouchScreenKeyboard.Open(text, keyboardType, autocorrection, multiline, secure, alert, textPlaceholder, characterLimit);
    }

    /// <summary>
    ///   <para>Opens the native keyboard provided by OS on the screen.</para>
    /// </summary>
    /// <param name="text">Text to edit.</param>
    /// <param name="keyboardType">Type of keyboard (eg, any text, numbers only, etc).</param>
    /// <param name="autocorrection">Is autocorrection applied?</param>
    /// <param name="multiline">Can more than one line of text be entered?</param>
    /// <param name="secure">Is the text masked (for passwords, etc)?</param>
    /// <param name="alert">Is the keyboard opened in alert mode?</param>
    /// <param name="textPlaceholder">Text to be used if no other text is present.</param>
    /// <param name="characterLimit">How many characters the keyboard input field is limited to. 0 = infinite. (Android and iOS only)</param>
    [ExcludeFromDocs]
    public static TouchScreenKeyboard Open(
      string text,
      TouchScreenKeyboardType keyboardType,
      bool autocorrection)
    {
      int characterLimit = 0;
      string textPlaceholder = "";
      bool alert = false;
      bool secure = false;
      bool multiline = false;
      return TouchScreenKeyboard.Open(text, keyboardType, autocorrection, multiline, secure, alert, textPlaceholder, characterLimit);
    }

    /// <summary>
    ///   <para>Opens the native keyboard provided by OS on the screen.</para>
    /// </summary>
    /// <param name="text">Text to edit.</param>
    /// <param name="keyboardType">Type of keyboard (eg, any text, numbers only, etc).</param>
    /// <param name="autocorrection">Is autocorrection applied?</param>
    /// <param name="multiline">Can more than one line of text be entered?</param>
    /// <param name="secure">Is the text masked (for passwords, etc)?</param>
    /// <param name="alert">Is the keyboard opened in alert mode?</param>
    /// <param name="textPlaceholder">Text to be used if no other text is present.</param>
    /// <param name="characterLimit">How many characters the keyboard input field is limited to. 0 = infinite. (Android and iOS only)</param>
    [ExcludeFromDocs]
    public static TouchScreenKeyboard Open(string text, TouchScreenKeyboardType keyboardType)
    {
      int characterLimit = 0;
      string textPlaceholder = "";
      bool alert = false;
      bool secure = false;
      bool multiline = false;
      bool autocorrection = true;
      return TouchScreenKeyboard.Open(text, keyboardType, autocorrection, multiline, secure, alert, textPlaceholder, characterLimit);
    }

    /// <summary>
    ///   <para>Opens the native keyboard provided by OS on the screen.</para>
    /// </summary>
    /// <param name="text">Text to edit.</param>
    /// <param name="keyboardType">Type of keyboard (eg, any text, numbers only, etc).</param>
    /// <param name="autocorrection">Is autocorrection applied?</param>
    /// <param name="multiline">Can more than one line of text be entered?</param>
    /// <param name="secure">Is the text masked (for passwords, etc)?</param>
    /// <param name="alert">Is the keyboard opened in alert mode?</param>
    /// <param name="textPlaceholder">Text to be used if no other text is present.</param>
    /// <param name="characterLimit">How many characters the keyboard input field is limited to. 0 = infinite. (Android and iOS only)</param>
    [ExcludeFromDocs]
    public static TouchScreenKeyboard Open(string text)
    {
      int characterLimit = 0;
      string textPlaceholder = "";
      bool alert = false;
      bool secure = false;
      bool multiline = false;
      bool autocorrection = true;
      TouchScreenKeyboardType keyboardType = TouchScreenKeyboardType.Default;
      return TouchScreenKeyboard.Open(text, keyboardType, autocorrection, multiline, secure, alert, textPlaceholder, characterLimit);
    }

    /// <summary>
    ///   <para>Returns the text displayed by the input field of the keyboard.</para>
    /// </summary>
    public extern string text { [NativeName("GetText"), MethodImpl(MethodImplOptions.InternalCall)] get; [NativeName("SetText"), MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Will text input field above the keyboard be hidden when the keyboard is on screen?</para>
    /// </summary>
    public static extern bool hideInput { [NativeName("IsInputHidden"), MethodImpl(MethodImplOptions.InternalCall)] get; [NativeName("SetInputHidden"), MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Is the keyboard visible or sliding into the position on the screen?</para>
    /// </summary>
    public extern bool active { [NativeName("IsActive"), MethodImpl(MethodImplOptions.InternalCall)] get; [NativeName("SetActive"), MethodImpl(MethodImplOptions.InternalCall)] set; }

    [FreeFunction("TouchScreenKeyboard_GetDone")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool GetDone(IntPtr ptr);

    /// <summary>
    ///   <para>Specifies if input process was finished. (Read Only)</para>
    /// </summary>
    [Obsolete("Property done is deprecated, use status instead")]
    public bool done => TouchScreenKeyboard.GetDone(this.m_Ptr);

    [FreeFunction("TouchScreenKeyboard_GetWasCanceled")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool GetWasCanceled(IntPtr ptr);

    /// <summary>
    ///   <para>Specifies if input process was canceled. (Read Only)</para>
    /// </summary>
    [Obsolete("Property wasCanceled is deprecated, use status instead.")]
    public bool wasCanceled => TouchScreenKeyboard.GetWasCanceled(this.m_Ptr);

    /// <summary>
    ///   <para>Returns the status of the on-screen keyboard. (Read Only)</para>
    /// </summary>
    public extern TouchScreenKeyboard.Status status { [NativeName("GetKeyboardStatus"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>How many characters the keyboard input field is limited to. 0 = infinite.</para>
    /// </summary>
    public extern int characterLimit { [NativeName("GetCharacterLimit"), MethodImpl(MethodImplOptions.InternalCall)] get; [NativeName("SetCharacterLimit"), MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Specifies whether the TouchScreenKeyboard supports the selection property. (Read Only)</para>
    /// </summary>
    public extern bool canGetSelection { [NativeName("CanGetSelection"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>Specifies whether the TouchScreenKeyboard supports the selection property. (Read Only)</para>
    /// </summary>
    public extern bool canSetSelection { [NativeName("CanSetSelection"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>Gets or sets the character range of the selected text within the string currently being edited.</para>
    /// </summary>
    public RangeInt selection
    {
      get
      {
        RangeInt selection;
        TouchScreenKeyboard.GetSelection(out selection.start, out selection.length);
        return selection;
      }
      set
      {
        if (value.start < 0 || value.length < 0 || value.start + value.length > this.text.Length)
          throw new ArgumentOutOfRangeException(nameof (selection), "Selection is out of range.");
        TouchScreenKeyboard.SetSelection(value.start, value.length);
      }
    }

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void GetSelection(out int start, out int length);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetSelection(int start, int length);

    /// <summary>
    ///   <para>Returns the TouchScreenKeyboardType of the keyboard.</para>
    /// </summary>
    public extern TouchScreenKeyboardType type { [NativeName("GetKeyboardType"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>Specified on which display the on-screen keyboard will appear.</para>
    /// </summary>
    public int targetDisplay
    {
      get => 0;
      set
      {
      }
    }

    /// <summary>
    ///   <para>Returns portion of the screen which is covered by the keyboard.</para>
    /// </summary>
    [NativeConditional("ENABLE_ONSCREEN_KEYBOARD", "RectT<float>()")]
    public static Rect area
    {
      [NativeName("GetRect")] get
      {
        Rect ret;
        TouchScreenKeyboard.get_area_Injected(out ret);
        return ret;
      }
    }

    /// <summary>
    ///   <para>Returns true whenever any keyboard is visible on the screen.</para>
    /// </summary>
    public static extern bool visible { [NativeName("IsVisible"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void get_area_Injected(out Rect ret);

    /// <summary>
    ///   <para>The status of the on-screen keyboard.</para>
    /// </summary>
    public enum Status
    {
      /// <summary>
      ///   <para>The on-screen keyboard is visible.</para>
      /// </summary>
      Visible,
      /// <summary>
      ///   <para>The user has finished providing input.</para>
      /// </summary>
      Done,
      /// <summary>
      ///   <para>The on-screen keyboard was canceled.</para>
      /// </summary>
      Canceled,
      /// <summary>
      ///   <para>The on-screen keyboard has lost focus.</para>
      /// </summary>
      LostFocus,
    }

    /// <summary>
    ///   <para>Android specific on-screen keyboard settings.</para>
    /// </summary>
    public class Android
    {
      /// <summary>
      ///   <para>Enable legacy on-screen keyboard hiding on Android.</para>
      /// </summary>
      [Obsolete("TouchScreenKeyboard.Android.closeKeyboardOnOutsideTap is obsolete. Use TouchScreenKeyboard.Android.consumesOutsideTouches instead (UnityUpgradable) -> UnityEngine.TouchScreenKeyboard/Android.consumesOutsideTouches")]
      public static bool closeKeyboardOnOutsideTap
      {
        get => TouchScreenKeyboard.Android.consumesOutsideTouches;
        set => TouchScreenKeyboard.Android.consumesOutsideTouches = value;
      }

      /// <summary>
      ///   <para>Indicates whether the keyboard consumes screen touches outside the visible keyboard area.</para>
      /// </summary>
      public static bool consumesOutsideTouches
      {
        set
        {
          TouchScreenKeyboard.Android.TouchScreenKeyboard_SetAndroidKeyboardConsumesOutsideTouches(value);
        }
        get
        {
          return TouchScreenKeyboard.Android.TouchScreenKeyboard_GetAndroidKeyboardConsumesOutsideTouches();
        }
      }

      [FreeFunction("TouchScreenKeyboard_SetAndroidKeyboardConsumesOutsideTouches")]
      [NativeConditional("PLATFORM_ANDROID")]
      [MethodImpl(MethodImplOptions.InternalCall)]
      private static extern void TouchScreenKeyboard_SetAndroidKeyboardConsumesOutsideTouches(
        bool enable);

      [FreeFunction("TouchScreenKeyboard_GetAndroidKeyboardConsumesOutsideTouches")]
      [NativeConditional("PLATFORM_ANDROID")]
      [MethodImpl(MethodImplOptions.InternalCall)]
      private static extern bool TouchScreenKeyboard_GetAndroidKeyboardConsumesOutsideTouches();
    }
  }
}
